﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace Framework_Tool
{

    public partial class StaffView : Page
    {
        MainWindow main;

        public StaffView()
        {
            InitializeComponent();
        }

        private void mainContent_Loaded(object sender, RoutedEventArgs e)
        {
            // displayStaffDetailsLstvw.Items.Clear();
            Database.populateStaffListview(this);

            viewStaff.FontWeight = FontWeights.ExtraBold;
            addStaff.FontWeight = FontWeights.Normal;
            updateStaff.FontWeight = FontWeights.Normal;
            deleteStaff.FontWeight = FontWeights.Normal;
            searchStaff.FontWeight = FontWeights.Normal;
        }

        private void addStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffAdd stfAddWindow = new StaffAdd(main);
            stfAddWindow.Content = null;
            mainContent.Children.Add(stfAddWindow.mainContent);
        }

        private void updateStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffUpdate stfUpdateWindow = new StaffUpdate();
            stfUpdateWindow.Content = null;
            mainContent.Children.Add(stfUpdateWindow.mainContent);
        }
        private void deleteStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffDelete stfDeleteWindow = new StaffDelete();
            stfDeleteWindow.Content = null;
            mainContent.Children.Add(stfDeleteWindow.mainContent);
        }

        private void searchStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffSearch stfSearchWindow = new StaffSearch();
            stfSearchWindow.Content = null;
            mainContent.Children.Add(stfSearchWindow.mainContent);
        }

        private void stfView_Update_Click_1(object sender, RoutedEventArgs e)
        {
            StaffUpdate stfUpdateWindow = new StaffUpdate();
            stfUpdateWindow.Content = null;
            mainContent.Children.Add(stfUpdateWindow.mainContent);

            DataRowView dr = (DataRowView)displayStaffDetailsLstvw.SelectedItem;
            string x = dr.Row["userID"].ToString();
            stfUpdateWindow.stfIDUpdateCmbx.Text = x;
        }
        
        private void stfView_Delete_Click_1(object sender, RoutedEventArgs e)
        {
            StaffDelete stfDeleteWindow = new StaffDelete();
            stfDeleteWindow.Content = null;
            mainContent.Children.Add(stfDeleteWindow.mainContent);

            DataRowView drv = (DataRowView)displayStaffDetailsLstvw.SelectedItem;
            string x = drv.Row["userID"].ToString();
            stfDeleteWindow.stfIDDeleteCmbx.Text = x;
        }

        private void stfView_Cancel_Click_1(object sender, RoutedEventArgs e)
        {
            displayStaffDetailsLstvw.SelectedItem = null;
        }
    }
}
